//==========================================================================
// Copyright (c) 2000-2006,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#define C_SYMBOL(symbol)    _##symbol

.global C_SYMBOL(GetCxt)
C_SYMBOL(GetCxt):
    stmdb   sp!, {r1-r3,lr}

    stmdb   r0!, {r0-r12,lr}
    mrs     r1, cpsr
    mov     r2, lr
    add     r3, sp, #0x38    /*fixup sp*/
    stmdb   r0!, {r1-r3}

    ldmia   sp!, {r1-r3,pc}

.global C_SYMBOL(Reboot)
C_SYMBOL(Reboot):
//////////////////////////////
//    ldr     r0, =0xa2c00000
//    ldr     r1, =0xa3c00000
//    ldr     r2, =0x100
//    ldr     sp, =0xa0020000
//////////////////////////////
    //Copy code to stack before jump
    adr     lr, copybegin
    ldmia   lr, {r3-r12}            //4*10
    stmdb   sp!, {r3-r12}

    mcr     p15, 0, r0, c7, c10, 4  //Drain write (& fill) buffer

    add     r2, r2, r1
    mov     lr, r0
    mov     pc, sp
    mov     r0, r0
    sub     pc, pc, #4

copybegin:
    ldmia   r1!, {r3-r12}
    stmia   r0!, {r3-r12}           //Unsafe!Sorry
    cmp     r1, r2
    bcc     copybegin

    mcr     p15, 0, r0, c7, c10, 4
    mcr     p15, 0, r0, c7, c5, 0   //Invalidate I cache
    mrc     p15, 0, r0, c2, c0, 0
    mov     r0, r0
    sub     pc, pc, #4
    mov     pc, lr
copyend:
#==========================================================================
